#ifndef CSVROW_H
#define CSVROW_H

#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>

const char c_delm = '|';

class CsvRow
{
public:
  const std::string& operator[](std::size_t index) const
  {
    return m_data[index];
  }

  std::size_t size() const
  {
    return m_data.size();
  }

  bool empty() const
  {
    return m_data.empty();
  }

  void readNextRow(std::istream& str)
  {
    std::string line;
    std::getline(str, line);

    std::stringstream lineStream(line);
    std::string cell;

    m_data.clear();
    while(std::getline(lineStream, cell, c_delm))
      m_data.push_back(cell);
  }
private:
  std::vector<std::string> m_data;
};

static std::istream& operator>>(std::istream& str,CsvRow& data)
{
  data.readNextRow(str);
  return str;
}

#endif // CSVROW_H